import Router from 'vue-router';

const views=NodeJs.readViews('../views')
const uiPages=NodeJs.readViews('../uiPages')


const routes = [];
uiPages.forEach(function (view){
  routes.push({
    path: '/ui/' + view,
    component: () => {
      return import(/* webpackChunkName: "[request]"  */ `../uiPages/${view}`)
    }
  })
})
routes.push({
  path: '/ui/*',
  component: () => {
    return import(/* webpackChunkName: "[request]"  */ `../uiPages/index`)
  }
})
views.forEach(function (view){
  routes.push({
    path: '*/' + view,
    name:view,
    component: () => {
      return import(/* webpackChunkName: "[request]"  */ `../views/${view}`)
    }
  })
})

routes.push({
  path: '*',
  name:'index',
  component: () => {
    return import(/* webpackChunkName: "[request]"  */ `../views/index`)
  }
})
const router = new Router({
  mode: 'hash',
  routes: routes,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})

export default router;